<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="com.lgx.right.entity.User,com.lgx.common.web.Constants"  %>
<%
	String path = request.getContextPath();
	//获取当前登录用户的类型
	User user = (User) request.getSession().getAttribute(Constants.LOGIN_USER);   //自动抓取当前用户的信息
	int mumberType = user.getUserType();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<%=path%>/css/admin_type.css" rel="stylesheet" type="text/css">
<jsp:include page="/page/head.jsp"></jsp:include>
<script type="text/javascript" src="<%=path %>/js/timeout.js"></script>
<script type="text/javascript">
	//修改当前登录人密码
	/* 生成jbox对话窗口 */
		function openPassword(){
			var html = "<div style='padding:10px;'>"+
						"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='3'>输入原密码:</font>&nbsp;&nbsp;&nbsp;&nbsp;<input type='password' id='opwd' name='opwd' length='80'/><br/>"+
			 			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='3'>输入新密码:</font>&nbsp;&nbsp;&nbsp;&nbsp;<input type='password' id='npwd' name='npwd' length='80' /><br/>"+
			   			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='3'>重复新密码:</font>&nbsp;&nbsp;&nbsp;&nbsp;<input type='password' id='rpwd' name='rpwd' length='80' />"+
						"</div>";
			   
			var data = {};    //不可去除，一旦去除，提交按钮将失效
            var states = {};
            states.state1 = {
            	    content: html,
            	    buttons: {'修改': 1, '取消': 0 },
            	    submit: function (v, h, f) {
            	        if (v == 0) {
            	            return true;                           // 关闭窗口
            	        }else {
            	        	h.find('.errorBlock').hide('fast', function () { $(this).remove(); });
            	            data.opwd = f.opwd;
            	            
            	            //参数非空验证
            	            if(data.opwd == "" || parseInt(data.opwd) < 1){
            	            	$('<div class="errorBlock" style="display: none;"><font color="red" size="2">请输入操作密码!</font></div>').prependTo(h).show('fast');
            	            	return false;
            	            }
            	            
            	            data.npwd = f.npwd;
            	            if(data.npwd.length <6 || data.npwd.length > 16){    //密码长度限制验证
            	            	$('<div class="errorBlock" style="display: none;"><font color="red" size="2">密码不能小于6位或者是大于16位!</font></div>').prependTo(h).show('fast');
            	            	return false;
            	            }
            	            
            	            data.rpwd = f.rpwd;
            	            if(data.rpwd == "" ||data.npwd != data.rpwd){    //密码一致性判断
            	            	$('<div class="errorBlock" style="display: none;"><font color="red" size="2">前后密码不一致!</font></div>').prependTo(h).show('fast');
            	            	return false;
            	            }
            	            
            	            // 验证通过执行Ajax后台操作
            	            $.ajax({
								  url:path +"/user/modifyPassword.do?opwd="+data.opwd+"&npwd="+data.npwd,
								  success: function(data) {
									  if(data == "1"){
										    $.jBox.nextState(); 
		  			                        var msg = [];
		  						            msg.push('<div class="msg-div">');
		  						            msg.push('<p>操作已完成，修改成功!</p>');                                                  
		  						            msg.push('</div>');
			  		                        window.setTimeout(function () { $.jBox.nextState(msg.join('')); }, 2000);    
			  		                        //刷新页面
			  		                        $('#mgrTable').datagrid('reload');
			  		        			    $('#mgrTable').datagrid('clearSelections');
									   }else if(data == "0"){
										    $.jBox.nextState(); 
		  			                        var msg = [];
		  						            msg.push('<div class="msg-div">');
		  						            msg.push('<p>操作中断，输入的操作密码有误，您无权修改!</p>');                                                 
		  						            msg.push('</div>');
			  		                        window.setTimeout(function () { $.jBox.nextState(msg.join('')); }, 2000);   
									   } else{
										   	$.jBox.nextState(); 
		  			                        var msg = [];
		  						            msg.push('<div class="msg-div">');
		  						            msg.push('<p>操作已完成，修改失败!</p>');                                                  
		  						            msg.push('</div>');
			  		                        window.setTimeout(function () { $.jBox.nextState(msg.join('')); }, 2000);    
									   }
								  }
							}); 
							
            	            
            	        }

            	        return false;
            	    }
            };
            states.state2 = {
                content: '<div class="msg-div">正在处理...</div>',
                buttons: {}   // no buttons
            };
            states.state3 = {
            	    content: '',
            	    buttons: { '确定': 0 }
           };

            $.jBox.open(states,'修改密码',400,'auto'); 
	}
</script>
<title>乐共享后台管理系统</title>
</head>

<body>
	<div id="box" lang="en">
		<!-- s Head -->
		<div class="head">
			<div class="logo">
				<img src="<%=path%>/images/logo.jpg" width="140" height="116" /> 
				<img	src="<%=path%>/images/logo2.jpg" width="258" height="36"	class="l2" />
			</div>
			<div class="topnav">
				<ol>
					<li><a href="#">返回首页</a></li>
					<li><a href="<%=path %>/user/logout.do">退出</a></li>
					<li><a href="<%=path %>/user/updateLoginUser.do" target="mainFrame">个人资料修改</a></li>
					<li><a href="javascript:void(0);" onclick="openPassword()">修改密码</a></li>
					<li class="date">今天是：${currentDate}</li>
				</ol>
				<p>
					<b class="redfont">${s_user.truename}</b>，欢迎来到乐共享管理中心！
				</p>
			</div>
		</div>
		<!-- end Head -->
		<!-- Left 管理菜单 -->
		<div class="left2">
			<h1>管理菜单</h1>
			<iframe src="initMenus.do" name="leftFrame" id="leftFrame"
				marginheight="0px" style="width: 195px; height: 600px; float: left;"
				align="top" scrolling="no"></iframe>
		</div>
		<!-- main -->
		<iframe src="<%=path%>/page/main.jsp" name="mainFrame" id="mainFrame"
			marginheight="0px" style="width: 800px; height: 626px; float: left;"
			align="top" scrolling="auto"></iframe>
	</div>
</body>
</html>